<?php
# file_service.php
# Author: Jason Ganzhorn

if($_POST["task"] == "export") {
	header("Content-type: application/octet-stream");
	header("Content-Disposition: attachment; filename=\"file.bob\"");
	$layers = json_decode($_POST["layers"]);
	for($i = 0; $i < count($layers); $i++) {
		$output .= "[$i]\n";
		$output .= json_encode($layers[$i]) . "\n";
	}
	echo $output;
}

if($_POST["task"] == "import") {
	$lines = file($_FILES['bobfile']['tmp_name']);
	var_dump($lines);
}

#$test = json_decode($_POST["layers"]);
?>
